package priv.yiyuan.example.design.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * 信用卡支付
 * <p>
 * 抽象子类
 */
public class CreditCardPayment extends Payment {

    private String cardNumber;

    private String expiryDate;

    private String cvv;

    public CreditCardPayment(PaymentProcessor paymentProcessor, String cardNumber, String expiryDate, String cvv) {
        super(paymentProcessor);
        this.cardNumber = cardNumber;
        this.expiryDate = expiryDate;
        this.cvv = cvv;
    }

    @Override
    public boolean makePayment(double amount) {

        Map<String, String> details = new HashMap<>();
        details.put("cardNumber", cardNumber);
        details.put("expiryDate", expiryDate);
        details.put("cvv", cvv);

        return paymentProcessor.processPayment(amount, details);
    }

    @Override
    public boolean requestRefund(double amount) {
        return paymentProcessor.refund(amount, super.getTransactionId());
    }
}
